<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <h1>我是计数器<span id='count'>0</span></h1>
        <button onclick='test1()'>点击加一</button>
    </div>
    <script src="./lodash.min.js"></script>
    <!-- 节流：在规定的事件间隔内不会重复触发回调，只有大于这个事件间隔才会触发回调，把频繁触发变为少量触发 -->
    <script>
        let count = document.getElementById('count')
        let num = 0

        // 需求：计数器1s之内数字最多增加一次

        function test() {
            count.innerHTML = ++num;
            console.log('执行节流函数');
        }

        // 节流，这个回调函数5s执行一次
        let test1 = _.throttle(test, 1000)
    </script>
</body>

</html>